package com.xm.servlet.reception_desk.login;

import lombok.SneakyThrows;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * 退出登陆
 * @author 康文程
 * @date 2023-12-26
 */
@WebServlet("/login/out")
public class LoginOutServlet extends HttpServlet {
    /**
     * 退出登陆
     * @param req   an {@link HttpServletRequest} object that
     *                  contains the request the client has made
     *                  of the servlet
     *
     * @param resp  an {@link HttpServletResponse} object that
     *                  contains the response the servlet sends
     *                  to the client
     *
     */
    @SneakyThrows
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
        //删除令牌和账号ID
        HttpSession session = req.getSession();
        session.removeAttribute("token");
        session.removeAttribute("account");
        resp.sendRedirect("/www.xiaomi.com/shop");
    }
}
